// pages/driver/evaluate/evaluate.js
var api = require("../../../api.js"),
    app = getApp();
var handler=require('../../../utils/function.js');
Page({
    /**
     * 页面的初始数据
     */
    data: {
      img: handler.userImg,
        evaluateList: [{
            title: "技术棒",
            count: 5
        }, {
            title: "人超好",
            count: 5
        }, {
            title: "服务好",
            count: 5
        }, {
            title: "驾驶平稳",
            count: 5
        }, {
            title: "有礼貌",
            count: 5
        }, {
            title: "专业",
            count: 5
        }, {
            title: "神准时",
            count: 5
        }, {
            title: "接驾太慢",
            count: 5
        }, ],
        page:1,
        evaluate: [],
        percentage: 0,
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
      // 获取优惠券
      if (options.uid) {
        app.shareCouponsMessage(options.uid)
      }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        var that = this;
        wx.showLoading({})
        app.request({
            url: api.order_comment.commentlist,
            method: 'post',
            data: {},
            success: function(rs) {
              wx.hideLoading()
                console.log('代驾人员评论列表', rs);
                that.setData({
                    evaluateList: rs.data.problem,
                    evaluate: rs.data.res.data,
                    percentage: rs.data.percentage,
                })
            }
        })
        /* this.setData({
             evaluate: wx.getStorageSync("evaluate")
         });*/
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {
        var that = this;
        // 显示加载图标  
        wx.showNavigationBarLoading();
        var page=this.data.page;
        page++;
        
      this.setData({ page})
      var evaluate = this.data.evaluate;
        app.request({
            url: api.order_comment.commentlist,
            method: 'post',
            data: {
              page: page
            },
            success: function(rs) { 
              var evaluates= rs.data.res.data; 
              if(evaluates.length!=0){
                for (var i = 0; i < evaluates.length;i++){
                  evaluate.push(evaluates[i])
                }
              }
              console.log('代驾人员评论列表', rs);
                that.setData({
                    evaluateList: rs.data.problem,
                  evaluate: evaluate,
                    percentage: rs.data.percentage,
                });
                wx.hideNavigationBarLoading()
            }
        })
    },
  // 用户分享
  onShareAppMessage: function () {
    let title = app.shareAppMessage().title;
    let imageUrl = app.shareAppMessage().imageUrl;
    let desc = app.shareAppMessage().desc;
    let path = app.shareAppMessage().path;
    console.log(app.shareAppMessage())
    return {
      title: title,
      imageUrl: imageUrl,
      desc: desc,
      path: path,
    }
  },
})